// @Title  data_cache.go
// @Description  缓存采集到的数据
// @Author  IT搬运工
// @Update
package container

import (
	"time"

	"github.com/patrickmn/go-cache"
)

//通道状态
type ChannelStatus struct {
	IsRun bool
}

//设备连接状态

var cacheTemplate *cache.Cache

func init() {
	c := cache.New(5*time.Minute, 10*time.Minute)
	cacheTemplate = c
}

//永久的设置缓存
func NoExpirationSet(key string, value interface{}) {
	Set(key, value, cache.NoExpiration)
}

//删除缓存
func DeleteCache(key string) {
	cacheTemplate.Delete(key)
}

//指定时间缓存数据
func Set(key string, value interface{}, time time.Duration) {
	cacheTemplate.Set(key, value, time)
}

//获取缓存值
func Get(key string) (interface{}, bool) {
	return cacheTemplate.Get(key)
}
